package com.ts.admin.modules.content.category.job;

import com.dk.feign.api.Admin2CategoryService;
import com.ts.admin.modules.job.task.ITask;
import com.ts.admin.modules.sys.service.SysParamsService;
import com.ts.common.core.constant.CategoryConstant;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;


@Slf4j
@Component
public class HotCircleTask implements ITask {

    @Autowired
    private Admin2CategoryService admin2CategoryService;

    @Autowired
    private SysParamsService sysParamsService;

    @Override
    public void run(String params) {
        // 获取热门个数参数
        String hotCircleNum = sysParamsService.getValue(CategoryConstant.CIRCLE_HOT_NUM_CODE);

        // 创建新线程处理
        new Thread(()->{
            // 远程调用
            admin2CategoryService.calculateCircleHot(Integer.parseInt(hotCircleNum));
        }).start();

        log.info("刷新热门圈子成功");
    }
}
